
:root {
  --text-input-font-size: 16px;
  --text-input-height: 31px;
  --text-input-border-color: var(--input-border-color);
  --material-text-input-font-size: 16px;
  --material-text-input-color: var(--material-text-input-text-color);

  @define-mixin text-input {
    @mixin input;
    @mixin transparent;
    letter-spacing: 0;
    box-shadow: none;
    color: var(--input-text-color);
    padding: 0;
    margin: 0;
    width: auto;
    font-size: var(--text-input-font-size);
    height: var(--text-input-height);
    font-weight: var(--font-weight);
    box-sizing: border-box;
  }

  @define-mixin text-input--disabled {
    @mixin disabled;
  }

  @define-mixin text-input--focus {
  }

  @define-mixin input-placeholder {
    @mixin transparent;
    color: var(--input-placeholder-color);
  }

  @define-mixin text-input--invalid {
    @mixin transparent;
    color: var(--input-invalid-text-color);
  }

  @define-mixin text-input-underbar-disabled {
    @mixin input-placeholder;
    border: none;
    background-color: transparent;
  }

  @define-mixin text-input--material-placeholder {
    color: var(--material-text-input-inactive-color);
    line-height: 20px;
  }
}

/*~
  name: Text Input
  category: Text Input
  elements: ons-input
  markup: |
    <div><input type="text" class="text-input" placeholder="text" value=""></div>
    <div><input type="text" class="text-input" placeholder="text" value="" disabled></div>
*/

.text-input {
  @mixin text-input;
}

.text-input::-ms-clear {
  display: none;
}

.text-input:disabled {
  @mixin text-input--disabled;
}

.text-input::placeholder {
  color: var(--input-placeholder-color);
}

.text-input:disabled::placeholder {
  @mixin input-placeholder;
}

.text-input:invalid {
  @mixin text-input--invalid;
}

/*~
  name: Underbar Text Input
  category: Text Input
  elements: ons-input
  markup: |
    <div><input type="text" class="text-input text-input--underbar" placeholder="text" value=""></div>
    <div><input type="text" class="text-input text-input--underbar" placeholder="text" value="" disabled></div>
*/

.text-input--underbar {
  @mixin text-input;
  border: none;
  background-color: transparent;
  border-bottom: 1px solid var(--text-input-border-color);
  border-radius: 0;
}

.text-input--underbar:disabled {
  @mixin text-input--disabled;
  border: none;
  background-color: transparent;
  border-bottom: 1px solid var(--text-input-border-color);
}

.text-input--underbar:disabled::placeholder {
  @mixin text-input-underbar-disabled;
}

.text-input--underbar:invalid {
  @mixin text-input--invalid;
  border: none;
  background-color: transparent;
  border-bottom: 1px solid var(--input-invalid-border-color);
}

/*~
  name: Material Input
  category: Text Input
  elements: ons-input
  markup: |
    <span>
      <div><input class="text-input text-input--material" placeholder="Username" type="text" required></div>
      <br />
      <div><input class="text-input text-input--material" placeholder="Password" type="password" required></div>
    </span>
*/

.text-input--material {
  @mixin input;
  @mixin material-font;
  color: var(--material-text-input-color);
  background-image: linear-gradient(to top, transparent 1px, var(--material-text-input-inactive-color) 1px);
  background-size: 100% 2px;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-color: transparent;
  font-size: var(--material-text-input-font-size);
  font-weight: 400;
  border: none;
  padding-bottom: 2px;
  border-radius: 0;
  height: 24px;
  vertical-align: middle;
  -webkit-transform: translate3d(0, 0, 0); /* FIXME: prevent ios flicker */
}

.text-input--material__label {
  @mixin material-font;
  color: var(--material-text-input-inactive-color);
  position: absolute;
  left: 0;
  top: 2px;
  font-size: 16px;
  font-weight: 400;
  pointer-events: none;
}

.text-input--material__label--active {
  color: var(--material-text-input-active-color);
  transform: translate(0, -75%) scale(0.75);
  transform-origin: left top;
  transition: transform 0.1s ease-in, color 0.1s ease-in;
}

.text-input--material:focus {
  background-image:
    linear-gradient(var(--material-text-input-active-color), var(--material-text-input-active-color)),
    linear-gradient(to top, transparent 1px, var(--material-text-input-inactive-color) 1px);
  animation: material-text-input-animate 0.3s forwards;
}

.text-input--material::placeholder {
  @mixin text-input--material-placeholder;
}

@keyframes material-text-input-animate {
  0% {
    background-size: 0% 2px, 100% 2px;
  }

  100% {
    background-size: 100% 2px, 100% 2px;
  }
}
